package com.ac.api.component.config;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Bean;

import javax.annotation.PreDestroy;

@Configuration
public class OssConfig {
    private static final String endpoint = "oss-cn-hangzhou.aliyuncs.com";

    private static final String accessKeyId= "LTAI5tFAiAq9SjM9vaucMuYD";

    private static final String accessKeySecret= "RHDmRIOaYlEXe9t1ro7ls8Ejcnhigv";

//    private static final String bucketName="guojunjie";

    private OSS ossClient;


    @Bean
    public OSS getSssClient() {
        ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
        return ossClient;
    }

    @PreDestroy
    public void onDestroy() {
        ossClient.shutdown();
    }

}
